import {createRouter, createWebHistory} from 'vue-router'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/list',
            name: 'list',
            meta: {
                title: '商品列表'
            },
            component: () => import('../views/ListView.vue'),
        },
        {
            path: '/cart',
            name: 'cart',
            meta: {
                title: '商品详情'
            },
            component: () => import('../views/CartView.vue'),
        },
        {
            path: '/product/:id',
            name: 'product',
            meta: {
                title: '购物车'
            },
            component: () => import('../views/ProductView.vue'),
        },
        {
            path: '/:a*', // 路由地址
            redirect: '/list', // 重定向
        },
    ],
})

export default router
